{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "Braginskii coefficients\n",
    "=========================\n",
    "\n",
    "A short example of how to calculate classical transport coefficients\n",
    "from Bragiński's theory.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "import astropy.units as u\n",
    "\n",
    "from plasmapy.formulary import ClassicalTransport"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We'll use some sample ITER data, without much regard for whether\n",
    "the regime is even fit for classical transport theory:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "thermal_energy_per_electron = 8.8 * u.keV\n",
    "electron_concentration = 10.1e19 / u.m**3\n",
    "\n",
    "thermal_energy_per_ion = 8.0 * u.keV\n",
    "ion_concentration = electron_concentration\n",
    "ion = \"D+\"  # a crude approximation"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    "We now make the default :class:`~plasmapy.formulary.braginskii.ClassicalTransport` object:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "braginskii = ClassicalTransport(\n",
    "    thermal_energy_per_electron,\n",
    "    electron_concentration,\n",
    "    thermal_energy_per_ion,\n",
    "    ion_concentration,\n",
    "    ion,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These variables are calculated during initialization and can be\n",
    "referred to straight away:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "print(braginskii.coulomb_log_ei)\n",
    "print(braginskii.coulomb_log_ii)\n",
    "print(braginskii.hall_e)\n",
    "print(braginskii.hall_i)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These quantities are not calculated during initialization and can be\n",
    "referred to via methods. To signify the need to calculate them, we\n",
    "call them via ().\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "print(braginskii.resistivity)\n",
    "print(braginskii.thermoelectric_conductivity)\n",
    "print(braginskii.electron_thermal_conductivity)\n",
    "print(braginskii.ion_thermal_conductivity)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "They also change with magnetization:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "mag_braginskii = ClassicalTransport(\n",
    "    thermal_energy_per_electron,\n",
    "    electron_concentration,\n",
    "    thermal_energy_per_ion,\n",
    "    ion_concentration,\n",
    "    ion,\n",
    "    B=0.1 * u.T,\n",
    ")\n",
    "\n",
    "print(mag_braginskii.resistivity)\n",
    "print(mag_braginskii.thermoelectric_conductivity)\n",
    "print(mag_braginskii.electron_thermal_conductivity)\n",
    "print(mag_braginskii.ion_thermal_conductivity)"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    "They also change with direction with respect to the magnetic field. Here,\n",
    "we choose to print out, as arrays, the (parallel, perpendicular,\n",
    "and cross) directions. Take a look at the docs to\n",
    ":class:`~plasmapy.formulary.braginskii.ClassicalTransport`\n",
    "for more information on these."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "all_direction_braginskii = ClassicalTransport(\n",
    "    thermal_energy_per_electron,\n",
    "    electron_concentration,\n",
    "    thermal_energy_per_ion,\n",
    "    ion_concentration,\n",
    "    ion,\n",
    "    B=0.1 * u.T,\n",
    "    field_orientation=\"all\",\n",
    ")\n",
    "\n",
    "print(all_direction_braginskii.resistivity)\n",
    "print(all_direction_braginskii.thermoelectric_conductivity)\n",
    "print(all_direction_braginskii.electron_thermal_conductivity)\n",
    "print(all_direction_braginskii.ion_thermal_conductivity)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The viscosities return arrays:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "print(braginskii.electron_viscosity)\n",
    "print(mag_braginskii.electron_viscosity)\n",
    "print(braginskii.ion_viscosity)\n",
    "print(mag_braginskii.ion_viscosity)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
